package com.laobiao.file_netty_lib.netty.client;

import com.laobiao.file_netty_lib.netty.BytesToPacketDecoder;
import com.laobiao.file_netty_lib.netty.PacketToBytesEncoder;
import com.laobiao.file_netty_lib.netty.client.handler.ClientHandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.FixedLengthFrameDecoder;

public class ClientInitializer extends ChannelInitializer<SocketChannel>{
	private ClientHandler handler;
	public ClientInitializer(ClientHandler handler) {
		this.handler=handler;
	}
	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		// TODO Auto-generated method stub
		ch.pipeline().addLast(new FixedLengthFrameDecoder(1024))
		.addLast(new PacketToBytesEncoder())
		.addLast(new BytesToPacketDecoder())
		.addLast(handler);
		
	}

}
